﻿namespace Vibstudio.NetConfigurator.Globalization
{
    public class Labeler
    {
        #region Fields

        private static ILabeler _labeler;
        private static string _lang;

        #endregion

        #region Ctor(s)

        private Labeler(string lang)
        {
            _lang = lang;
        }

        #endregion

        #region Factory methods

        public static Labeler Setup(string lang)
        {
            return new Labeler(lang);
        }

        public static Labeler Setup()
        {
            return Setup(string.Empty);
        }

        #endregion

        #region Properties

        public static ILabeler Get
        {
            get
            {
                if (_labeler == null) InitializeLabeler();
                return _labeler;
            }
        }

        #endregion

        #region Private methods

        private static void InitializeLabeler()
        {
            if (string.IsNullOrEmpty(_lang)) _lang = string.Empty;
            switch (_lang.ToLower())
            {
                case "it":
                case "ita":
                    _labeler = new ItalianLabeler();
                    break;
                case "en":
                case "eng":
                    _labeler = new EnglishLabeler();
                    break;
                case "de":
                case "ger":
                    _labeler = new GermanLabeler();
                    break;
                default:
                    _labeler = new EnglishLabeler();
                    break;
            }
        }

        #endregion
    }
}
